<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
  var ary=[34,56,12,66,12]
  function insertSort(ary){
    //定义一个最总排好序的盒子
    var newAry=[]
    //拿出第一项放进去
    newAry.push(ary[0])
    for(var i=1;i<ary.length;i++){
      var OldItem=ary[i]
      for(var j=newAry.length-1;j>=0;j--){
        var newItemAry=newAry[j]
        if(oldItem>=newItemAry){
          newAry.splice(j+1,0,oldItem)
          break
        }
        if(j==0){
          newAry.unshift(oldItem)
        }
      }
    }
  }
  console.log(newAry)
  
  
  </script>
</body>
</html>